#-*-encoding=utf-8-*-
steps = [
    FlowStep(
        name=u'init',
        title=u'分发申请',
        fields=[u'doc', u'recipients', u'start', u'description'],
        responsibles=u'lasttask is None and [request.principal.id] or sheet["creators"]',
    actions=[
        FlowStepAction(
            name=u'submit',
            title=u'提交',
            nextsteps=[u'review'],
            finish_condition=u''
)
])
,

    FlowStep(
        name=u'review',
        title=u'分发审核',
        fields=[u'recipients', u'start', u'doc'],
        responsibles=u'flowsettings["reviewer"]',
    actions=[
        FlowStepAction(
            name=u'accept',
            title=u'通过',
            nextsteps=[u'end'],
            trigger=ur"""# 通知分发人员
docs = []
for docid in sheet['doc']:
    title = IDublinCore(intids.getObject(docid)).title
    docs.append(title)

titles = ', '.join(docs)

msg_notifier.send('有受控文档将分发给您', 
                 '文档 ： %s' % titles, 
                 sheet['recipients'],
                 bound_obj=sheet)
"""
),

        FlowStepAction(
            name=u'reject',
            title=u'打回',
            nextsteps=[u'init'],
            finish_condition=u''
)
])
,

    FlowStep(
        name=u'end',
        title=u'文档签收',
        fields=[],
        responsibles=u'sheet["recipients"]',
    actions=[
        FlowStepAction(
            name=u'265145',
            title=u'收到',
            nextsteps=[u'910699'],
            finish_condition=u"task.vote('收到')"
)
])
,

    FlowStep(
        name=u'910699',
        title=u'验收',
        fields=[],
        responsibles=u'flowsettings["reviewer"]',
    actions=[
        FlowStepAction(
            name=u'656199',
            title=u'通过',
            nextsteps=[],
            trigger=ur"""# 验收通过，将分发名单计入文档附加属性中
for docid in sheet['doc']:
    doc = intids.getObject(docid)

    holders = IFieldStorage(doc).get('isodoc_holders', [])[:]
    for pid in sheet['recipients']:
        if pid not in holders:
            holders.append(pid)
    IFieldStorage(doc)['isodoc_holders'] = holders
"""
)
])
]
